/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Admin_AddPromo.java
 *
 * Created on Mar 30, 2011, 6:17:03 PM
 */
package admin_gui;

import admin.BusinessLogic.Validation;
import admin.Controller.PromoController;
import java.util.regex.Pattern;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

/**
 *
 * @author edaype
 */
public class Admin_AddPromo extends javax.swing.JPanel {

    private PromoController promoController;
    private JPanel mainPanel;
    private Validation validation;

    /** Creates new form Admin_AddPromo */
    public Admin_AddPromo() {
        initComponents();
        validation = new Validation();
        promoController = new PromoController(mainPanel);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        ItemPanel = new javax.swing.JPanel();
        PNameLabel = new javax.swing.JLabel();
        PNameField = new javax.swing.JTextField();
        PAmountLabel = new javax.swing.JLabel();
        PAmountField = new javax.swing.JTextField();
        StartPanel = new javax.swing.JPanel();
        StartYearLabel = new javax.swing.JLabel();
        StartYearCombo = new javax.swing.JComboBox();
        StartDayCombo = new javax.swing.JComboBox();
        StartMonthLabel = new javax.swing.JLabel();
        StartDayLabel = new javax.swing.JLabel();
        StartLabel = new javax.swing.JLabel();
        StartMonthCombo = new javax.swing.JComboBox();
        EndPanel = new javax.swing.JPanel();
        EndtYearLabel = new javax.swing.JLabel();
        EndYearCombo = new javax.swing.JComboBox();
        EndDayCombo = new javax.swing.JComboBox();
        EndMonthLabel = new javax.swing.JLabel();
        EndDayLabel = new javax.swing.JLabel();
        EndLabel = new javax.swing.JLabel();
        EndMonthCombo = new javax.swing.JComboBox();
        StoreCardCheck = new javax.swing.JCheckBox();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        ButtonPanel = new javax.swing.JPanel();
        ResetButton = new javax.swing.JButton();
        AddButton = new javax.swing.JButton();
        AddPromoLabel = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 255));

        ItemPanel.setBackground(new java.awt.Color(255, 255, 255));

        PNameLabel.setFont(new java.awt.Font("Tahoma", 0, 24));
        PNameLabel.setText("Promotion Name");

        PNameField.setFont(new java.awt.Font("Tahoma", 0, 24));

        PAmountLabel.setFont(new java.awt.Font("Tahoma", 0, 24));
        PAmountLabel.setText("Promotion Amount");

        PAmountField.setFont(new java.awt.Font("Tahoma", 0, 24));

        StartPanel.setBackground(new java.awt.Color(255, 255, 255));

        StartYearLabel.setFont(new java.awt.Font("Tahoma", 0, 18));
        StartYearLabel.setText("Year");

        StartYearCombo.setFont(new java.awt.Font("Tahoma", 0, 18));
        StartYearCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020" }));

        StartDayCombo.setFont(new java.awt.Font("Tahoma", 0, 18));
        StartDayCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        StartMonthLabel.setFont(new java.awt.Font("Tahoma", 0, 18));
        StartMonthLabel.setText("Month");

        StartDayLabel.setFont(new java.awt.Font("Tahoma", 0, 18));
        StartDayLabel.setText("Day");

        StartLabel.setFont(new java.awt.Font("Tahoma", 0, 24));
        StartLabel.setText("Start Date");

        StartMonthCombo.setFont(new java.awt.Font("Tahoma", 0, 18));
        StartMonthCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" }));

        javax.swing.GroupLayout StartPanelLayout = new javax.swing.GroupLayout(StartPanel);
        StartPanel.setLayout(StartPanelLayout);
        StartPanelLayout.setHorizontalGroup(
            StartPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, StartPanelLayout.createSequentialGroup()
                .addContainerGap(68, Short.MAX_VALUE)
                .addComponent(StartLabel)
                .addGap(27, 27, 27)
                .addGroup(StartPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(StartPanelLayout.createSequentialGroup()
                        .addComponent(StartMonthCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(StartDayCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(StartYearCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, StartPanelLayout.createSequentialGroup()
                        .addComponent(StartMonthLabel)
                        .addGap(67, 67, 67)
                        .addComponent(StartDayLabel)
                        .addGap(71, 71, 71)
                        .addComponent(StartYearLabel)
                        .addGap(35, 35, 35)))
                .addGap(64, 64, 64))
        );
        StartPanelLayout.setVerticalGroup(
            StartPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(StartPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(StartPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(StartYearLabel)
                    .addComponent(StartDayLabel)
                    .addComponent(StartMonthLabel))
                .addGap(4, 4, 4)
                .addGroup(StartPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(StartMonthCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(StartDayCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(StartYearCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(StartLabel))
                .addContainerGap())
        );

        EndPanel.setBackground(new java.awt.Color(255, 255, 255));

        EndtYearLabel.setFont(new java.awt.Font("Tahoma", 0, 18));
        EndtYearLabel.setText("Year");

        EndYearCombo.setFont(new java.awt.Font("Tahoma", 0, 18));
        EndYearCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020" }));

        EndDayCombo.setFont(new java.awt.Font("Tahoma", 0, 18));
        EndDayCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        EndMonthLabel.setFont(new java.awt.Font("Tahoma", 0, 18));
        EndMonthLabel.setText("Month");

        EndDayLabel.setFont(new java.awt.Font("Tahoma", 0, 18));
        EndDayLabel.setText("Day");

        EndLabel.setFont(new java.awt.Font("Tahoma", 0, 24));
        EndLabel.setText("End Date");

        EndMonthCombo.setFont(new java.awt.Font("Tahoma", 0, 18));
        EndMonthCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" }));

        javax.swing.GroupLayout EndPanelLayout = new javax.swing.GroupLayout(EndPanel);
        EndPanel.setLayout(EndPanelLayout);
        EndPanelLayout.setHorizontalGroup(
            EndPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, EndPanelLayout.createSequentialGroup()
                .addContainerGap(82, Short.MAX_VALUE)
                .addComponent(EndLabel)
                .addGap(26, 26, 26)
                .addGroup(EndPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(EndPanelLayout.createSequentialGroup()
                        .addComponent(EndMonthCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(EndDayCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(EndYearCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, EndPanelLayout.createSequentialGroup()
                        .addComponent(EndMonthLabel)
                        .addGap(67, 67, 67)
                        .addComponent(EndDayLabel)
                        .addGap(71, 71, 71)
                        .addComponent(EndtYearLabel)
                        .addGap(35, 35, 35)))
                .addGap(63, 63, 63))
        );
        EndPanelLayout.setVerticalGroup(
            EndPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(EndPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(EndPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(EndtYearLabel)
                    .addComponent(EndDayLabel)
                    .addComponent(EndMonthLabel))
                .addGap(4, 4, 4)
                .addGroup(EndPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(EndMonthCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(EndDayCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(EndYearCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(EndLabel))
                .addContainerGap())
        );

        StoreCardCheck.setBackground(new java.awt.Color(255, 255, 255));
        StoreCardCheck.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        StoreCardCheck.setText("StoreCard Required");

        jLabel1.setFont(new java.awt.Font("宋体", 0, 24));

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 24));
        jLabel2.setText("%");

        javax.swing.GroupLayout ItemPanelLayout = new javax.swing.GroupLayout(ItemPanel);
        ItemPanel.setLayout(ItemPanelLayout);
        ItemPanelLayout.setHorizontalGroup(
            ItemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ItemPanelLayout.createSequentialGroup()
                .addGroup(ItemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ItemPanelLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(PNameLabel)
                        .addGap(27, 27, 27)
                        .addComponent(PNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 305, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ItemPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(ItemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(StartPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(EndPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(ItemPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(PAmountLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(PAmountField, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(ItemPanelLayout.createSequentialGroup()
                        .addGap(168, 168, 168)
                        .addComponent(StoreCardCheck))
                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 590, Short.MAX_VALUE))
                .addContainerGap())
        );
        ItemPanelLayout.setVerticalGroup(
            ItemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ItemPanelLayout.createSequentialGroup()
                .addGap(85, 85, 85)
                .addGroup(ItemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(PNameLabel)
                    .addComponent(PNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(23, 23, 23)
                .addComponent(StartPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(EndPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(48, 48, 48)
                .addGroup(ItemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(ItemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(PAmountLabel)
                        .addComponent(PAmountField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(StoreCardCheck)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        ButtonPanel.setBackground(new java.awt.Color(255, 255, 255));

        ResetButton.setFont(new java.awt.Font("Tahoma", 0, 18));
        ResetButton.setText("Reset");
        ResetButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ResetButtonActionPerformed(evt);
            }
        });

        AddButton.setFont(new java.awt.Font("Tahoma", 0, 18));
        AddButton.setText("Add");
        AddButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AddButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout ButtonPanelLayout = new javax.swing.GroupLayout(ButtonPanel);
        ButtonPanel.setLayout(ButtonPanelLayout);
        ButtonPanelLayout.setHorizontalGroup(
            ButtonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ButtonPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(ResetButton, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(AddButton, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(71, Short.MAX_VALUE))
        );
        ButtonPanelLayout.setVerticalGroup(
            ButtonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ButtonPanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(ButtonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ResetButton, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(AddButton, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        AddPromoLabel.setFont(new java.awt.Font("Copperplate Gothic Bold", 2, 50));
        AddPromoLabel.setText("Add Promotion");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(24, 24, 24)
                        .addComponent(AddPromoLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(ButtonPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(88, 88, 88)
                        .addComponent(ItemPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(18, Short.MAX_VALUE)
                .addComponent(ItemPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(ButtonPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addComponent(AddPromoLabel)))
                .addGap(28, 28, 28))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void ResetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ResetButtonActionPerformed
        // TODO add your handling code here:
        PAmountField.setText("");
        PNameField.setText("");
        EndDayCombo.setSelectedIndex(0);
        EndMonthCombo.setSelectedIndex(0);
        EndYearCombo.setSelectedIndex(0);
        StartDayCombo.setSelectedIndex(0);
        StartMonthCombo.setSelectedIndex(0);
        StartYearCombo.setSelectedIndex(0);
        StoreCardCheck.setSelected(false);
    }//GEN-LAST:event_ResetButtonActionPerformed

    private void AddButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddButtonActionPerformed
        // TODO add your handling code here:
        String PName = PNameField.getText();
        String PAmountS = PAmountField.getText();
        String startDate = StartDayCombo.getSelectedItem().toString();
        String startMonth = StartMonthCombo.getSelectedItem().toString();
        String startYear = StartYearCombo.getSelectedItem().toString();
        String endDate = EndDayCombo.getSelectedItem().toString();
        String endMonth = EndMonthCombo.getSelectedItem().toString();
        String endYear = EndYearCombo.getSelectedItem().toString();

        if (!validation.ValidateStartDate(Integer.parseInt(startMonth), Integer.parseInt(
                startDate), Integer.parseInt(startYear),
                Integer.parseInt(endMonth), Integer.parseInt(endDate), Integer.parseInt(
                endYear))) {
            JOptionPane.showMessageDialog(null, "Sorry! Invalid date",
                    "Error", JOptionPane.ERROR_MESSAGE);
        } else if (PName.equals("") || PAmountS.equals("")) {
            JOptionPane.showMessageDialog(null, "Please input all information",
                    "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            if (validation.ValidateInteger(PAmountS)) {
                if ((Integer.parseInt(PAmountS) <= 100) && (Integer.parseInt(
                        PAmountS) >= 0)) {
                    int storeCard = 0;
                    if (StoreCardCheck.isSelected()) {
                        storeCard = 1;
                    }
                    double PAmountD = Double.parseDouble(PAmountS) / 100;
                    String sDate = startYear + "-" + startMonth + "-" +
                            startDate;
                    String eDate = endYear + "-" + endMonth + "-" + endDate;
                    boolean b = promoController.addPromo(PName, sDate, eDate,
                            PAmountD, storeCard);
          //          System.out.println("here ");
                    if (b) {
                        jLabel1.setText("Promotion " + PName +
                                " has registered successfully");
                        PAmountField.setText("");
                        PNameField.setText("");
                        EndDayCombo.setSelectedIndex(0);
                        EndMonthCombo.setSelectedIndex(0);
                        EndYearCombo.setSelectedIndex(0);
                        StartDayCombo.setSelectedIndex(0);
                        StartMonthCombo.setSelectedIndex(0);
                        StartYearCombo.setSelectedIndex(0);
                        StoreCardCheck.setSelected(false);
                    }
                } else {
                    JOptionPane.showMessageDialog(null,
                            "Please input positive number between 0 and 100!",
                            "Error", JOptionPane.ERROR_MESSAGE);
                }
            } else {
                JOptionPane.showMessageDialog(null,
                        "Please input positive number for 'Poromotion Amount'!",
                        "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    }//GEN-LAST:event_AddButtonActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton AddButton;
    private javax.swing.JLabel AddPromoLabel;
    private javax.swing.JPanel ButtonPanel;
    private javax.swing.JComboBox EndDayCombo;
    private javax.swing.JLabel EndDayLabel;
    private javax.swing.JLabel EndLabel;
    private javax.swing.JComboBox EndMonthCombo;
    private javax.swing.JLabel EndMonthLabel;
    private javax.swing.JPanel EndPanel;
    private javax.swing.JComboBox EndYearCombo;
    private javax.swing.JLabel EndtYearLabel;
    private javax.swing.JPanel ItemPanel;
    private javax.swing.JTextField PAmountField;
    private javax.swing.JLabel PAmountLabel;
    private javax.swing.JTextField PNameField;
    private javax.swing.JLabel PNameLabel;
    private javax.swing.JButton ResetButton;
    private javax.swing.JComboBox StartDayCombo;
    private javax.swing.JLabel StartDayLabel;
    private javax.swing.JLabel StartLabel;
    private javax.swing.JComboBox StartMonthCombo;
    private javax.swing.JLabel StartMonthLabel;
    private javax.swing.JPanel StartPanel;
    private javax.swing.JComboBox StartYearCombo;
    private javax.swing.JLabel StartYearLabel;
    private javax.swing.JCheckBox StoreCardCheck;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    // End of variables declaration//GEN-END:variables
}
